//
// Created by xili on 2024/8/14 10:13.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int numWaterBottles(int numBottles, int numExchange) {
        int ans = 0;
        while (numBottles) {
            numBottles += ans++ % numExchange == 0 ? 0 : -1;
        }
        return ans - 1;
    }
};